export const countDownFun = (time) => {
  time-- //时间一秒秒的减
  let nowTime = new Date().getTime(); //现在时间
  if (nowTime <= time) {
    time-- //获取时间差
    let timediff = Math.round((time - nowTime) / 1000)
    //获取还剩多少小时
    let hour = parseInt(timediff / 3600 % 24)
    //获取还剩多少分钟
    let minute = parseInt(timediff / 60 % 60)
    //获取还剩多少秒
    let second = timediff % 60
    // 增零处理
    hour = addPrev(hour)
    minute = addPrev(hour)
    second = addPrev(second)
    return {
      hour,
      minute,
      second
    }
  } else {
    return {
      hour: '',
      minute: '',
      second: ''
    }
  }
}

// 增零处理
function addPrev (t) {
  return t < 10 ? '0' + t : t
}
